home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / IRDA / IRTTP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  145 lines

  1. /*********************************************************************
  2.  *                
  3.  * Filename:      irttp.h
  4.  * Version:       1.0
  5.  * Description:   Tiny Transport Protocol (TTP) definitions
  6.  * Status:        Experimental.
  7.  * Author:        Dag Brattli <dagb@cs.uit.no>
  8.  * Created at:    Sun Aug 31 20:14:31 1997
  9.  * Modified at:   Mon Mar 22 13:17:30 1999
  10.  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  11.  * 
  12.  *     Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
  13.  *     
  14.  *     This program is free software; you can redistribute it and/or 
  15.  *     modify it under the terms of the GNU General Public License as 
  16.  *     published by the Free Software Foundation; either version 2 of 
  17.  *     the License, or (at your option) any later version.
  18.  *
  19.  *     Neither Dag Brattli nor University of Troms° admit liability nor
  20.  *     provide warranty for any of this software. This material is 
  21.  *     provided "AS-IS" and at no charge.
  22.  *
  23.  ********************************************************************/
  24.  
  25. #ifndef IRTTP_H
  26. #define IRTTP_H
  27.  
  28. #include <linux/types.h>
  29. #include <linux/skbuff.h>
  30. #include <asm/spinlock.h>
  31.  
  32. #include <net/irda/irda.h>
  33. #include <net/irda/irlmp.h>
  34. #include <net/irda/qos.h>
  35. #include <net/irda/irqueue.h>
  36.  
  37. #define TTP_MAX_CONNECTIONS    LM_MAX_CONNECTIONS
  38. #define TTP_HEADER             1
  39. #define TTP_HEADER_WITH_SAR    6
  40. #define TTP_PARAMETERS         0x80
  41. #define TTP_MORE               0x80
  42.  
  43. #define DEFAULT_INITIAL_CREDIT 22
  44.  
  45. #define LOW_THRESHOLD   4
  46. #define HIGH_THRESHOLD  8
  47. #define TTP_MAX_QUEUE  22
  48.  
  49. /* Some priorities for disconnect requests */
  50. #define P_NORMAL    0
  51. #define P_HIGH      1
  52.  
  53. #define SAR_DISABLE 0
  54. #define SAR_UNBOUND 0xffffffff
  55.  
  56. /*
  57.  *  This structure contains all data assosiated with one instance of a TTP 
  58.  *  connection.
  59.  */
  60. struct tsap_cb {
  61.     QUEUE queue;          /* For linking it into the hashbin */
  62.     int  magic;           /* Just in case */
  63.  
  64.     int max_seg_size;     /* Max data that fit into an IrLAP frame */
  65.  
  66.     __u8 stsap_sel;       /* Source TSAP */
  67.     __u8 dtsap_sel;       /* Destination TSAP */
  68.  
  69.     struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */
  70.  
  71.     __u8 connected;       /* TSAP connected */
  72.      
  73.     __u8 initial_credit;  /* Initial credit to give peer */
  74.  
  75.         int avail_credit;    /* Available credit to return to peer */
  76.     int remote_credit;   /* Credit held by peer TTP entity */
  77.     int send_credit;     /* Credit held by local TTP entity */
  78.     
  79.     struct sk_buff_head tx_queue; /* Frames to be transmitted */
  80.     struct sk_buff_head rx_queue; /* Received frames */
  81.     struct sk_buff_head rx_fragments;
  82.     int tx_queue_lock;
  83.     int rx_queue_lock;
  84.     spinlock_t lock;
  85.  
  86.     struct notify_t notify;       /* Callbacks to client layer */
  87.  
  88.     struct irda_statistics stats;
  89.     struct timer_list todo_timer; 
  90.     
  91.     int   rx_sdu_busy;     /* RxSdu.busy */
  92.     __u32 rx_sdu_size;     /* Current size of a partially received frame */
  93.     __u32 rx_max_sdu_size; /* Max receive user data size */
  94.  
  95.     int tx_sdu_busy;       /* TxSdu.busy */
  96.     int tx_max_sdu_size;   /* Max transmit user data size */
  97.  
  98.     int close_pend;        /* Close, but disconnect_pend */
  99.     int disconnect_pend;   /* Disconnect, but still data to send */
  100.     struct sk_buff *disconnect_skb;
  101. };
  102.  
  103. struct irttp_cb {
  104.     int magic;
  105.     
  106.     hashbin_t *tsaps;
  107. };
  108.  
  109. int  irttp_init(void);
  110. void irttp_cleanup(void);
  111.  
  112. struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, 
  113.                 struct notify_t *notify);
  114. int irttp_close_tsap(struct tsap_cb *self);
  115.  
  116. int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb);
  117. int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb);
  118.  
  119. int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, 
  120.               __u32 saddr, __u32 daddr,
  121.               struct qos_info *qos, __u32 max_sdu_size, 
  122.               struct sk_buff *userdata);
  123. void irttp_connect_confirm(void *instance, void *sap, struct qos_info *qos, 
  124.                __u32 max_sdu_size, struct sk_buff *skb);
  125. void irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, 
  126.                 struct sk_buff *userdata);
  127. struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance);
  128. void irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb,
  129.                   int priority);
  130. void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow);
  131.  
  132. static __inline __u32 irttp_get_saddr(struct tsap_cb *self)
  133. {
  134.     return irlmp_get_saddr(self->lsap);
  135. }
  136.  
  137. static __inline __u32 irttp_get_daddr(struct tsap_cb *self)
  138. {
  139.     return irlmp_get_daddr(self->lsap);
  140. }
  141.  
  142. extern struct irttp_cb *irttp;
  143.  
  144. #endif /* IRTTP_H */
  145.